#ifndef _LIST_H_
#define _LIST_H_

#include <stdlib.h>

#ifndef list_malloc
#define list_malloc malloc
#endif

#ifndef list_free
#define list_free free
#endif

typedef struct __list {
    struct __list *prev, *next;
    void *data;
} list_t;


list_t *list_new(void *data);

void list_del(list_t *x);

void list_init(list_t *list);

void list_insert(list_t *i, list_t *x);

void list_remove(list_t *x);

void list_append(list_t *list, list_t *x);

void list_prepend(list_t *list, list_t *x);

#define list_foreach(list, iter) \
    for (list_t *(iter) = (list); (iter); (iter) = (list)->next)


#endif
